#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 装饰器日志记录

import time
import functools

def log_exec_time(func):
    @functools.wraps(func)
    def wrapper(*args, **kw):
        start = time.perf_counter()
        res = func(*args, **kw)
        end = time.perf_counter()
        print('{} took {} ms'.format(func.__name__, (end - start) * 1000))
        return res
    return wrapper



@log_exec_time
def loop(n):
    for i in range(n):
        print(i)
        time.sleep(1)

loop(3)
